package com.second.app.thread.stream;

import java.io.IOException;
import java.io.PipedOutputStream;

/**
 * @author gyz
 * @date 2021/1/26 17:09
 */
public class WriteData {

    public static Integer loopCount = 300;

    public void writeMethod(PipedOutputStream outputStream) {

        try {
            System.out.println("线程："+Thread.currentThread().getName()+"开始writing......");
            for (int i = 0; i < loopCount; i++) {
                String outData = "" + (i + 1);
                outputStream.write(outData.getBytes());
                System.out.print(outData);
            }
            System.out.println();
            outputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
